package com.example.demo.service;

import com.example.demo.entity.UserQue;
import com.example.demo.entity.Userinfo;
import com.example.demo.entity.vo.UserinfoVO;
import com.example.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     *  注册
     */
    public Integer register(UserinfoVO userinfoVO) {
        return userMapper.register(userinfoVO);
    }

    /**
     *  登录
     */
    public Userinfo getUserByName(String username) {
        return userMapper.getUserByName(username);
    }

    /**
     *  7. 根据用户id查询列表页用户信息
     */
    public UserinfoVO getUserById(Integer id) {
        return userMapper.getUserById(id);
    }

    /**
     *  修改密码
     */
    public Integer updPassword(Userinfo userinfo) {
        return userMapper.updPassword(userinfo);
    }

    /**
     *  设置密保
     */
    public Integer addQuestion(UserQue userQue) {
        return userMapper.addQuestion(userQue);
    }

    /**
     *  logcount - 1
     */
    public void reduceLogCount(Integer logcount, Integer id) {
        userMapper.reduceLogCount(logcount, id);
    }
    /**
     *  设置状态码
     */
    public void setUserState(Integer state, Integer id) {
        userMapper.setUserState(state, id);
    }

    /**
     *  获取用户昵称
     */
    public String getNickName(Integer id) {
        return userMapper.getNickName(id);
    }

    /**
     *  修改用户昵称
     */
    public Integer updNickName(UserinfoVO userinfoVO) {
        return userMapper.updNickName(userinfoVO);
    }

    /**
     *  修改用户头像
     */
    public Integer upLodePhoto(String photo, Integer id) {
        return userMapper.upLodePhoto(photo, id);
    }

}
